package cn.tangsihai.hrm.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@Component
@Primary
public class DocumentationConfig implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
       List resources = new ArrayList<>();
       // 整合所有模块的接口，只要有就一直加就行
       resources.add(swaggerResource("系统管理", "/hrm/system/v2/api-docs", "2.0"));
       resources.add(swaggerResource("课程管理", "/hrm/course/v2/api-docs", "2.0"));
       resources.add(swaggerResource("认证中心", "/hrm/auth/v2/api-docs", "2.0"));
       resources.add(swaggerResource("文件中心", "/hrm/file/v2/api-docs", "2.0"));
       resources.add(swaggerResource("检索中心", "/hrm/search/v2/api-docs", "2.0"));
       resources.add(swaggerResource("消息中心", "/hrm/message/v2/api-docs", "2.0"));
       resources.add(swaggerResource("用户中心", "/hrm/user/v2/api-docs", "2.0"));
       return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}